package com.chanjiedata.changbs.view.pswkeyboard.widget;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;

import com.chanjiedata.changbs.R;
import com.chanjiedata.changbs.view.pswkeyboard.OnPasswordInputFinish;


/**
 * 输入支付密码
 *
 * @author lining
 */
public class PopPayEnterPassword extends PopupWindow {

    public PasswordPayView pwdView;

    private View mMenuView;

    private Activity mContext;



    public PopPayEnterPassword(final Activity context, OnPasswordInputFinish lis ) {

        super(context);
        this.mContext = context;

        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        mMenuView = inflater.inflate(R.layout.pop_enter_pay_password, null);

        pwdView = (PasswordPayView) mMenuView.findViewById(R.id.pwd_view);
        VirtualKeyboardView virtualKeyboardView = pwdView.getVirtualKeyboardView();




        //添加密码输入完成的响应
        pwdView.setOnFinishInput(lis);

        // 监听X关闭按钮
        pwdView.getImgCancel().setOnClickListener(v -> dismiss());

        // 监听键盘上方的返回
        pwdView.getVirtualKeyboardView().getLayoutBack().setOnClickListener(v -> dismiss());

        // 设置SelectPicPopupWindow的View
        this.setContentView(mMenuView);
        // 设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth(LayoutParams.MATCH_PARENT);
        // 设置SelectPicPopupWindow弹出窗体的高
        this.setHeight(LayoutParams.MATCH_PARENT);
        // 设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        // 设置SelectPicPopupWindow弹出窗体动画效果
        this.setAnimationStyle(R.style.pop_add_ainm);
        // 实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0x66000000);
        // 设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);

    }


}
